package com.xtz.controller;

import com.xtz.domain.Order;
import com.xtz.dto.PageDto;
import com.xtz.service.OrderService;
import com.xtz.vo.OrderPageVo;
import com.xtz.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * date: 2022/5/14 8:43
 *
 * @author xietianze
 */
@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 分页
     * @param dto
     * @return
     */
    @GetMapping("page")
    public Result page(PageDto dto){

        List<Order> page = orderService.getPage(dto);
        OrderPageVo orderPageVo = new OrderPageVo();
        orderPageVo.setCurrent(dto.getPage());
        orderPageVo.setTotal(1);
        orderPageVo.setRecords(page);
        orderPageVo.setSize(dto.getPageSize());

        return new Result(1,null,orderPageVo,null);
    }

    /**
     * 修改
     */
    @PutMapping
    public Result updatestatusById(@RequestBody Order order){
        Boolean aBoolean = orderService.updatestatusById(order.getStatus(),order.getId());

        return new Result(1,null,null,null);
    }
}
